<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>修改密码</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/shop/static/layui/css/layui.css" media="all" type="text/css">
    <link rel="stylesheet" href="/shop/static/css/public.css" media="all" type="text/css">
</head>
<body class="childrenBody">
	<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
	  <legend>修改密码</legend>
	</fieldset>
<form class="layui-form layui-row changePwd" id="changePwd">
	<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
		<div class="layui-input-block layui-red pwdTips">新密码必须两次输入一致才能修改成功</div>
		<div class="layui-form-item">
			<label class="layui-form-label">用户名</label>
			<div class="layui-input-block">
				<input type="text" value="${userName!''}" disabled class="layui-input layui-disabled">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">旧密码</label>
			<div class="layui-input-block">
				<input type="password" value="" name="passwordOld" placeholder="请输入旧密码" lay-verify="required" class="layui-input pwd">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">新密码</label>
			<div class="layui-input-block">
				<input type="password" value="" id="passwordNew" name="passwordNew" placeholder="请输入新密码" lay-verify="required" id="oldPwd" class="layui-input pwd">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">确认密码</label>
			<div class="layui-input-block">
				<input type="password" value="" id="passwordNewT"  placeholder="请确认密码" lay-verify="required" class="layui-input pwd">
			</div>
		</div>
	</div>
</form>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn" lay-submit lay-filter="form">立即修改</button>
			</div>
		</div>
<script src="/shop/static/layui/layui.js" charset="utf-8" type="text/javascript"></script>
<script type="text/javascript" src="/shop/static/js/common/jquery-2.1.0.min.js"></script>
    <script type="text/javascript">
    layui.use(['form'], function() {
        var form = layui.form,
            layer = layui.layer

            form.on('submit(form)', function() {
            	 if($("#passwordNew").val()!=$("#passwordNewT").val()){
                 	layer.msg('两次密码不一致！');
                 	return
                 }
                     $.ajax({
                         cache: true,
                         type: "POST",
                         url: "/shop/main/changePwdSave",
                         data: $('#changePwd').serialize(),
                         async: false,
                         error: function(request) {
                             layer.msg('系统错误！');
                         },
                         success: function(data) {
                             if(data.code == "1") {
                            	 layer.msg(data.msg, function(){ 
                            			  location.reload(); 
                            		}); 
                             } else {
                                 layer.msg(data.msg);
                             }
                         }
                     });
            })     

    });
    </script>
</body>
</html>